import {defineStore} from "pinia";
import {TagData} from "@/type/TagData.ts";

export const TagViewStore = defineStore('tagsViewsStore',{

    state: () => {

        return{
            visitedViews: [] as TagData[]
        }
    },

    actions: {

        addView(view: TagData){

            if (!this.visitedViews.some((v: TagData) => v === view)){
                this.visitedViews.push(view)
            }
        },

        delView(view: TagData){

            for (const [i,v] of this.visitedViews.entries()){
                if (v === view){
                    this.visitedViews.splice(i, 1)
                }
            }
        }
    }
})